<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>车辆违章查询</title>
    <link type="text/css" href="<c:url value='/resource/wx/newcss/common.css'/>" rel="stylesheet"/>
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/frozen.css'></c:url>">
    <script type="text/javascript" src="<c:url value='/resource/js/jquery-2.0.min.js'/>"></script>
    <script type="text/javascript" src="https://gaapi.jl.gov.cn/web/resource/js/os.analystic-1.1.min.js"></script>
    <script type="text/javascript" src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script src="<c:url value='/resource/js/common.js'/>" type="text/javascript"></script>

    <script type="text/javascript">

        $(function() {
            //车型类型
            var opHtml="";
/*            opHtml+='<option >请选择</option>'*/
            opHtml+='<c:forEach items="${listClwzType}" var="list"><option value="${list.val}">${list.title}</option></c:forEach>'
            $("#jdccllxbm").html(opHtml);
            $("#result").hide();
            $("#results").hide();
        });


       // var _preFix = getServerPreFix();
        //区域编码
        var cid = returnCitySN["cid"];
        var cip = returnCitySN["cip"];
        // 平台、不需传
        var category = "";
        cid = PrefixInteger(cid,12);

        // 区域代码12位、不足前面补0
        function PrefixInteger(num, length) {
            return (Array(length).join('0') + num).slice(-length);
        }

        //日志组件初始化[必须调用]
        var logger = Oceansoft.analy.init({
            'appId': '1001',
            'regionId': cid,
            'category': category
        });

        /**
         * Form表单日志统计
         */
        function formSubmit() {
//            var logData = "{'tag':'100005','category':'"+category+"','oper':'','oper_id':'','ip':'" + cip + "','title':'','ext':''}";
//            logger.start();
//            logger.log('100005', logger.ACTION.CREATE, logData);
            return true;
        }

        function check() {
            $("#result").hide();
            $("#results").hide();
//            var pushId = $("#pushId").val().trim();
//            var pushType = $("#pushType").val().trim();
            var rep = /[A-Z]{1}[A-Z_0-9_学_挂]{5}$/;
            var rep_num = /[a-z_A-Z_0-9_\-]{4}/;
            var jdchphm = $("#jdchphm").val().trim().toUpperCase();
            var fdj = $("#fdj").val().trim().toUpperCase();
            var jdccllxbm = $("#jdccllxbm").val().trim();
            var firnull = "车牌号不能为空";
            var secnull = "发动机后六位不能为空";
            var firformet = "车牌号格式不正确";
            var secformet = "请输入发动机后六位";
            var carType = "请选择车辆类型";
            if (jdchphm == null || jdchphm == "") {
                toast(firnull, 1500);
                return false;
            } else if (fdj == null || fdj == "") {
                toast(secnull, 1500);
                return false;
            } else if (!rep.test(jdchphm)) {
                toast(firformet, 1500);
                return false;
            } else if (!rep_num.test(fdj)) {
                toast(secformet, 1500);
                return false;
            }else {
                var html = "";

                $.ajax({
                    url: "<c:url value='/api/query/ytVehicle/illegals'/>",
                    type: "post",
                    data: $('#form').serialize(),
                    timeout : 200000,
                    beforeSend: function () {
                        loading();
                    },
                    complete: function(XMLHttpRequest,status){
                        if(status=='timeout'){//超时,status还有success,error等值的情况
                            alert("超时");
                        }
                    },
                    success: function (data) {
                        if (null!=data.data.result&&""!=data.data.result) {

                            $.each(data.data.result, function (index, police) {
                                var money= police.FKJE;
                                var why= police.WFXW;
                                if(null==money||""==money){
                                    money=0;
                                }
                                if(null==why||""==why){
                                    why="无违法原因"
                                }
                                html += '<div><p>第' +(++index)+ '条</p>' +
                                        '<p>违法时间: ' + police.WFSJ + '</p>' +
                                        '<p>违法地点: ' + police.WFDZ + '</p>' +
                                        '<p>违法行为: ' + why + '</p>' +
                                        '<p>违法记分数: ' + police.WFJFS + '</p>' +
                                        '<p>违法金额: ' + money + '元</p></div><hr/>';
                            });
                        }else{
                            html+="<p style='align:center'>无违法信息</p>"
                        }


                        finish();
                        formSubmit();
                        $("#result").show();
                        $("#results").show();
                        $("#result").html(data.msg);
                        $("#results").html(html);
//                        $("#btn_query").remove();
                    },
                    error: function () {
                        check();
                    }
                });
            }

        }

        function F() {
            $(".toast").hide();
        }
    </script>

    <style type="text/css">
        body {
            font-family: "微软雅黑";
        }

        .body_bg {
            background-color: #efefef
        }

        .bg_fff {
            background-color: #FFFFFF
        }

        .text_main {
            padding: 10px;
            padding-top: 0px;
            font-size: 16px;
            color: #333;
        }

        .search_table {
            width: 100%;
            font-size: 16px;
            color: #333;
        }

        .search_table td {
            height: 30px;
            line-height: 30px;
            text-align: left;
            text-indent: 10px;
        }

        .ui-form-item label:not(.ui-switch):not(.ui-checkbox):not(.ui-radio) {
            width: 126px;
        }

        .toast {
            display: none;
            position: absolute;
            bottom: 100px;
            text-align: center;
            width: 170px;
            white-space: nowrap;
            font-size: 1.0em;
            padding: 0.7em 1em 0.9em 1em;
            color: #fff;
            border-radius: 4px;
            background-color: rgba(0, 0, 0, 0.67);
            border: none;
            width: -moz-fit-content;
            width: -webkit-fit-content;
            height: -webkit-fit-content;
            width: fit-content;
            margin-left: auto;
            margin-right: auto;
            border: 0;
            left: 0;
            right: 0;
        }
    </style>
</head>

<body ontouchstart>

<%--<c:if test="${pt != 'I'}">
    <header class="ui-header ui-header-positive ui-border-b">
        <i class="ui-icon-return" onclick="history.back()"></i>
        <h1>机动车违法查询</h1>
    </header>
</c:if>--%>

<section class="ui-container">

    <div class="ui-form ui-border-t">
        <form action="#" id="form">

            <div class="ui-form-item ui-border-b">
                <label>车辆类型：</label>
                <div class="ui-select">
                    <select id="jdccllxbm" name="jdccllxbm">
                    </select>
                </div>
            </div>
            <div class="ui-form-item ui-border-b" style="position: relative;">
                <label>
                    号牌号码：云
                </label>
                <input id="jdchphm" name="jdchphm" type="text" style="padding-left: 105px;" maxLength="6"
                       placeholder="请输入六位车牌号" onkeyup="this.value=this.value.toUpperCase()" onfocus="hiden()"/>
            </div>

            <div class="ui-form-item ui-border-b">
                <label style="width: 128px;">
                    发动机号后六位：
                </label>
                <input id="fdj" name="fdj" type="text" style="padding-left: 128px;" maxLength="6" onkeyup="this.value=this.value.toUpperCase()" onfocus="hiden()"
                       placeholder="请输入您发动机号后六位"/>
            </div>

        </form>

    </div>

    <div class="ui-btn-wrap">
        <%--<input type="hidden" name="pushId" id="pushId" value="${pushId}" />--%>
        <%--<input type="hidden" name="pushType" id="pushType" value="${pushType}" />--%>
        <button class="ui-btn-lg ui-btn-primary" id="btn_query" onclick="check();">
            查询
        </button>
    </div>
    <div id="toast" class="toast" style="font-size: 1.0em;"></div>
    <div class="ui-form-item" id="result"></div>
    <div class="ui-form-item" id="results"></div>
</section>
</body>

</html>